import sys
from multiprocessing import Process, Queue
from time import sleep

sys.path.append('./common')
sys.path.append('./lcopa')
#sys.path.append('./web_server')
#from web.template import render
# import file
# import calculate_codev,load_uphi_data
# from lcopa import lcopa_usb
# from web_server import web_server
#
# from camery import read_camery2

from lcopa import calculate_codev,load_uphi_data,lcopa_usb
import lcopa_scan,camery.read_camery2
def f(q):
    while(1):
        q.put([42, None, 'hello'])
        sleep(100)

from tcp_server import rtdata_tcp_server,control_tcp_server
from camery import camery

if __name__ == '__main__':
    # print sys.path
    # u_phi = load_uphi_data.U_PHI
    # u_phi.load_uphi("./web/u-phi/DF2015-FA02.txt")
    # # calculate_codev.calculate_voltage(0.001)
    # usb = locpa_usb.LcopaUsb()
    # usb.open(0x1234)
    # while(1):
    #     pass
    # from camery import read_camery2
    #
    # # mlcopa_scan = lcopa_scan.LcopaScan(0x1234,"./web/u-phi/DF2015-FA02.txt",-0.01,0.01,0.0001)
    # q = Queue()
    # # p = Process(target=camery.read_camery2, args=(q,))
    # read_camery2.parse_pic(q)
    # p.start()
    # while(1):
    #     if(q.empty() == False):
    #         print "null"
    #     else:
    #         try:
    #             print q.get(True,1)
    #         except Exception,e:
    #             print "e:",e
    #         mlcopa_scan.next_scan()
    #     # print q.get(1)    # prints "[42, None, 'hello']"
    #
    # p.join()
    img_queue = Queue()

    rt_tcp_server = rtdata_tcp_server.RtDataTcpServer(img_queue)
    rt_process = Process(target=rt_tcp_server.start).start()
    con_tcp_server = control_tcp_server.TcpServer(img_queue)

    # cam = camery.Camery(q)
    # cam.parse_pic()
    while(True):
        value = input("quit?")
        break
    rt_tcp_server.close()
    con_tcp_server.close()

